//建立线性表，并且就地逆置

#include<stdio.h>
#include<stdlib.h>

typedef struct Node{
    int data;
    struct Node* next;
}Node,*LinkList;

int method1();
int method2();
Node* revers(Node* res);
int main(){
method2();
}

//法1
int method1(){
    int n;
    scanf("%d",&n);
    int i=0;
    Node *head,*next;
    head=(Node*)malloc(sizeof(Node));
    head->next=NULL;
    while(i<n){
        next = (Node*)malloc(sizeof(Node));
        int input;
        scanf("%d",&input);
        next->data=input;
        if(head->next==NULL){
            next->next=NULL;
        }else{
            next->next=head->next;
        }
        head->next=next;
        i++;
    }
    printf("res:%d,%d,%d",head->data,head->next->data,head->next->next->data);
    return 0;
}

int method2(){
    int n;
    scanf("%d",&n);
    int i=0;
    Node *head=NULL,*next;
    while(i<n){
        Node* newnode = (Node*)malloc(sizeof(Node));
        int input;
        scanf("%d",&input);
        newnode->data=input;
        if(head==NULL){
            head=newnode;
            next=newnode;
        }else{
            next->next=newnode;
            next=newnode;
        }
        i++;
    }
    Node* res = revers(head);
    printf("res:%d",res->data);
    return 0;
}

Node* revers(Node* head){
    Node* next=NULL;
    Node* curren=head;
    Node* tmp;
    while (curren!=NULL)
    {
        tmp=curren->next;
        curren->next=next;
        next=curren;
        curren=tmp;

    }
    return next;
}